﻿using System.Collections.Generic;
using System.Linq;
using System.Xml.Serialization;
using ElectronicCommerce.Framework.Configuration.Attributes;

namespace ElectronicCommerce.Framework.Web.Configuration.StringResource.Help
{
    [ConfigFile("~/Language/zh-cn/Help.config", ConfigPathType.ServerPath)]
    [XmlRoot("helpConfig", Namespace = "http://www.ElectronicCommerce.com/Language")]
    public class HelpResourceConfiguration
    {
        [XmlElement("helpInfo")]
        public HelpItemCollection HelpCollection
        {
            get;
            set;
        }

        public HelpItem GetHelpInfoById(int id)
        {
            return HelpCollection.Where(help => help.Id == id).SingleOrDefault<HelpItem>();
        }

        public IList<HelpItem> GetHelpListByCategoryId(int parentId)
        {
            return HelpCollection.Where(help => help.ParentId == parentId).ToList<HelpItem>();
        }
    }
}
